BIND
Section: System Calls (2)
Index
Return to Main Contents
BSD mandoc
BSD 4.2
NAME
bind
- bind a name to a socket
SYNOPSIS
Fd #include <sys/types.h>
Fd #include <sys/socket.h>
Ft int
Fn bind int s struct sockaddr *name int namelen
DESCRIPTION
Fn Bind
assigns a name to an unnamed socket.
When a socket is created
with
socket(2)
it exists in a name space (address family)
but has no name assigned.
Fn Bind
requests that
Fa name
be assigned to the socket.
NOTES
Binding a name in the UNIX domain creates a socket in the file
system that must be deleted by the caller when it is no longer
needed (using
unlink(2)).
The rules used in name binding vary between communication domains.
Consult the manual entries in section 4 for detailed information.
RETURN VALUES
If the bind is successful, a 0 value is returned.
A return value of -1 indicates an error, which is
further specified in the global
errno
ERRORS
The
Fn bind
call will fail if:
- Bq Er EBADF
-
Fa S
is not a valid descriptor.
- Bq Er ENOTSOCK
-
Fa S
is not a socket.
- Bq Er EADDRNOTAVAIL
-
The specified address is not available from the local machine.
- Bq Er EADDRINUSE
-
The specified address is already in use.
- Bq Er EINVAL
-
The socket is already bound to an address.
- Bq Er EACCES
-
The requested address is protected, and the current user
has inadequate permission to access it.
- Bq Er EFAULT
-
The
Fa name
parameter is not in a valid part of the user
address space.
The following errors are specific to binding names in the UNIX domain.
- Bq Er ENOTDIR
-
A component of the path prefix is not a directory.
- Bq Er ENAMETOOLONG
-
A component of a pathname exceeded
{NAME_MAX}
characters, or an entire path name exceeded
{PATH_MAX}
characters.
- Bq Er ENOENT
-
A prefix component of the path name does not exist.
- Bq Er ELOOP
-
Too many symbolic links were encountered in translating the pathname.
- Bq Er EIO
-
An I/O error occurred while making the directory entry or allocating the inode.
- Bq Er EROFS
-
The name would reside on a read-only file system.
- Bq Er EISDIR
-
An empty pathname was specified.
SEE ALSO
connect(2),
listen(2),
socket(2),
getsockname(2)
HISTORY
The
Fn bind
function call appeared in
BSD 4.2
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- NOTES
-
- RETURN VALUES
-
- ERRORS
-
- SEE ALSO
-
- HISTORY
-
This document was created by
man2html,
using the manual pages.
Time: 19:41:53 GMT, December 25, 2022